package com.party.course.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.party.common.annotation.Anonymous;
import com.party.common.annotation.Log;
import com.party.common.core.controller.BaseController;
import com.party.common.core.domain.AjaxResult;
import com.party.common.enums.BusinessType;
import com.party.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.party.course.domain.NoticeInfo;
import com.party.course.service.INoticeInfoService;
import com.party.common.core.page.TableDataInfo;

/**
 * 通知信息Controller
 *
 * @author songkaiyue
 * @date 2025-07-04
 */
@RestController
@RequestMapping("/course/noticeInfo")
public class NoticeInfoController extends BaseController {
    @Autowired
    private INoticeInfoService noticeInfoService;

    @Log(title = "test", businessType = BusinessType.OTHER)
    @GetMapping("/test")
    public String test() {
        return "test Susses";
    }

    /**
     * 查询通知信息列表
     */
//@RequiresPermissions("course:noticeInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(NoticeInfo noticeInfo) {
        startPage();
        List<NoticeInfo> list = noticeInfoService.findList(noticeInfo);
        return getDataTable(list);
    }

    /**
     * 导出通知信息列表
     */
    //@RequiresPermissions("course:noticeInfo:export")
    @Log(title = "通知信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NoticeInfo noticeInfo) {
        List<NoticeInfo> list = noticeInfoService.findList(noticeInfo);
        ExcelUtil<NoticeInfo> util = new ExcelUtil<NoticeInfo>(NoticeInfo.class);
        util.exportExcel(response, list, "通知信息数据");
    }

    /**
     * 获取通知信息详细信息
     */
    //@RequiresPermissions("course:noticeInfo:query")
    @GetMapping(value = "/view/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(noticeInfoService.view(id));
    }

    /**
     * 新增通知信息
     */
    //@RequiresPermissions("course:noticeInfo:add")
    @Log(title = "通知信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody NoticeInfo noticeInfo) {
        return toAjax(noticeInfoService.add(noticeInfo));
    }

    /**
     * 修改通知信息
     */
    //@RequiresPermissions("course:noticeInfo:edit")
    @Log(title = "通知信息", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody NoticeInfo noticeInfo) {
        return toAjax(noticeInfoService.updateEntity(noticeInfo));
    }

    /**
     * 删除通知信息
     */
    //@RequiresPermissions("course:noticeInfo:remove")
    @Log(title = "通知信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(noticeInfoService.deleteIds(Arrays.asList(ids)));
    }
}
